package com.han.walkman.service.impl;

import com.han.walkman.dao.CaseDao;
import com.han.walkman.entity.CaseEntity;
import com.han.walkman.service.CaseService;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author: Hanjiafeng
 * @Date: 2020/5/7
 * @Desc:
 */
@Service
public class CaseServiceImpl implements CaseService {

    private final CaseDao caseDao;

    public CaseServiceImpl(CaseDao caseDao) {
        this.caseDao = caseDao;
    }

    @Override
    public void add(CaseEntity caseEntity) {
        caseDao.save(caseEntity);
    }

    @Override
    public void delete(CaseEntity caseEntity) {
        caseDao.delete(caseEntity);
    }

    @Override
    public void update(CaseEntity caseEntity) {
        caseDao.save(caseEntity);
    }

    @Override
    public List<CaseEntity> findAll() {
        return caseDao.findAll();
    }

    @Override
    public Page<CaseEntity> findAll(Pageable pageable) {
        return caseDao.findAll(pageable);
    }

    @Override
    public List<CaseEntity> findAll(Example<CaseEntity> entityExample) {
        return caseDao.findAll(entityExample);
    }

    @Override
    public Page<CaseEntity> findAll(Example<CaseEntity> entityExample, Pageable pageable) {
        return caseDao.findAll(entityExample, pageable);
    }

    @Override
    public Optional<CaseEntity> findById(Integer id) {
        return caseDao.findById(id);
    }
}
